package com.pcbly.web.components.utils.template.pagemess;

import java.lang.reflect.Field;

import com.pcbly.web.components.utils.template.TemplateModel;
 
public abstract class IModelPageAndMessage {

	public abstract void execute(Class<?> clz);
	
	protected void execute(TemplateModel model, Field[] fields) throws Exception {
		ModelPageFactory factory = new ModelPageFactory();
		factory.setFields(fields);
		factory.setModel(model);

		ModelPage page;
		page = new ModelPageList();
		factory.setPage(page);
		factory.execute();

		page = new ModelPageEdit();
		factory.setPage(page);
		factory.execute();

		page = new ModelPageView();
		factory.setPage(page);
		factory.execute();

		page.printMessages();// print message. in order to i18n.
	}

}